﻿
using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;

namespace YouHP.Pages.SymptomHistory
{
    public class Index : YouHP.Pages.PatientBasePage
    {
        private const int SymptomBaseHeight = 110;
        private const int SymptomYGap = 30;
        protected int SymptomGraphHeight = SymptomBaseHeight + SymptomYGap;
        protected List<DiseaseSymptomInfo> PrimarySymptomList;

        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;

            HandleCommon();
            if (ErrorCount > 0) return;

            if (IsPost) HandlePost();
            else HandleGet();
        }

        protected List<SymptomHistoryInfo> CurrentSymptomList;
        protected List<SymptomHistoryInfo> CurrentPrimarySymptomList = new List<SymptomHistoryInfo>();
        protected List<SymptomHistoryInfo> CurrentOtherSymptomList = new List<SymptomHistoryInfo>();

        protected new void HandleCommon()
        {
            this.AddLocation("症状记录", "/SymptomHistory/Index.aspx");
            this.SetTitle("症状记录");
        }

        protected new void HandlePost()
        {

        }

        protected new void HandleGet()
        {
            int groupCount = 1;
            CurrentSymptomList = PatientSymptomBLL.Instance.GetCurrentSymptomList(PrData.Id);
            foreach (SymptomHistoryInfo info in CurrentSymptomList)
            {
                if (info.Type == Constants.PRIMARY_SYMPTOM)
                {
                    CurrentPrimarySymptomList.Add(info);
                }
                else
                {
                    CurrentOtherSymptomList.Add(info);
                    groupCount = 2;
                }
            }
            PrimarySymptomList = DiseaseBLL.Instance.GetDiseaseSymptomList(PrData.DiseaseId, Constants.PRIMARY_SYMPTOM);
            //利用症状个数来计算flash高度
            SymptomGraphHeight += CurrentSymptomList.Count * SymptomYGap + (int)((groupCount - 1) * SymptomYGap * 1.5);;

        }
    }
}